package com.wenge.datagroup.storage.dataprocess;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @description
 * @Projectname: centrecollect_temp
 * @Author: lzh
 * @Data:2022/11/1 10:50
 * @Description: TODO
 */
public class WikiFilter {
    static Pattern remainContent = Pattern.compile("\\[\\[[^>]*\\]\\]");
    static String deleteRef = "<ref>[^>]*</ref>";
    static String deleteBrace="\\{\\{[^>]*\\}\\}";
    public static String filter(String originRecord){
        Matcher matcher = remainContent.matcher(originRecord);
        String result = originRecord;
        while (matcher.find()){
            String group = matcher.group();
            String substring = group.substring(2, group.length() - 2);
            result.replaceFirst(group,substring);
        }
        result=result.replaceAll(deleteRef, "");
        result=result.replaceAll(deleteBrace, "");
        return result;
    }
}
